﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Semantics;
using Semantics.Base;
using System.Runtime.InteropServices;

namespace Semantics.Example.ParserExample
{
    public partial class splitForm : Form
    {
        private string inputText;
        private int index;
        private SortedList<int, Semantics.Parse.AmbiguityResolver.CorrectNode> CorrectNodeList;
        private List<SemanticPosition> Candidates;
        public splitForm(string inputText, int index, SortedList<int, Semantics.Parse.AmbiguityResolver.CorrectNode> CorrectNodeList, List<SemanticPosition> Candidates)
        {
            this.inputText = inputText;
            this.index = index;
            this.CorrectNodeList = CorrectNodeList;
            this.Candidates = Candidates;
            InitializeComponent();
            string CandidateValue = Candidates[index].Value;
            string point = "我们分析的句子是‘" + inputText + "'对于子句'" + Candidates[index].Value + "'拆分正确的一项";
            this.label1.Text = point;
            for (int i = 0; i < Candidates[index].LanguageNodes.Count; i++)
            {
                LangNode temLangNode=Candidates[index].LanguageNodes[i];
                String newItem="";
                for(int j=0;i<temLangNode.Children.Count;j++)
                {
                    newItem=temLangNode.Children[j].Value;
                }
                this.listBox1.Items.Add(newItem);
            }
        }

        private void ButtonSubmit_Click(object sender, EventArgs e)
        {
            int selectIndex = this.listBox1.SelectedIndex;
            if (selectIndex == -1)
            {
                MessageBox.Show(this, "没有选择有效地项!");
                return;
            }
            else 
            {
                //对选择好的child看有没有必要继续拆分
                //if(Candidates[index].LanguageNodes[selectIndex])
            }
        }
    }
}
